<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
    <style>
        .item {
            display: flex;
        }
        
        .item>div {
            margin-right: 20px;
        }
    </style>
</head>

<body>
    <div id="app">
        <div v-for="(item,index) in bookList" class="item">
            <div>id:{{item.id}}</div>
            <div>书名:{{item.name}}</div>
            <div>价格:{{item.price}}</div>
            <div @click="del(item,index)">删除</div>
        </div>
    </div>
</body>
<script>
    new Vue({
        el: '#app',
        data: {
            bookList: [{
                    id: 1,
                    name: 'H5',
                    price: 19
                }, {
                    id: 2,
                    name: 'CSS',
                    price: 20
                }, {
                    id: 3,
                    name: 'JQ',
                    price: 21
                },

            ]
        },
        methods: {
            del(a1, a2) {
                console.log(a1, a2);
                this.bookList.splice(a2, 1);
            }
        }
    })
</script>

</html>